package com.kevin.jdbc.daoUtil;

import java.io.InputStream;
import java.util.Properties;

import com.kevin.jdbc.dao.UserDao;

public class DaoFactory {

	private static DaoFactory instance = new DaoFactory();
	private UserDao userDao = null;

	private DaoFactory() {
		Properties properties = new Properties();
		InputStream inStream = DaoFactory.class.getClassLoader()
				.getResourceAsStream("DaoConfig.properties");
		try {
			properties.load(inStream);
			String userDaoStr = properties.getProperty("userDao");
			this.userDao = (UserDao) Class.forName(userDaoStr).newInstance();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static DaoFactory getInstance() {
		return instance;
	}

	public UserDao GetUserDao() {
		return this.userDao;
	}
}
